/*
+--------------------------
| FreeloaderOS v0.0.1
|  - Microkernel
+--------------------------
| Written by Alec Hussey
| Copyright (c) 2007
|  - Deus X Foundation
+---------------------------
*/

/*
 * Screensaver
 */

#include <system.h>
#include "main.h"

void init_screensaver()
{
	int i, j, x;
	unsigned int status = 0;
	unsigned int current_color = 0;
	
	x = 0;
	clear_screen();
	do
	{
		for (i = 0; i < 15; i++)
		{
			for (j = 0; j < 80; j++)
			{
				if (j == x)
				{
					set_text_color(get_color(current_color), 0x0);
					putch('+');
				}
				else
				{
					set_text_color(0xF, 0x0);
					putch('=');
				}
			}
			
			if (current_color == 15)
				current_color = 0;
			else
				current_color += 1;
			timer_wait(1);
			
			if (x == 80)
				x = 0;
			else
				x += 1;
		}
		timer_wait(20);
	}
	while (status != 1);
}

inline unsigned char get_color(int color)
{
	switch (color)
	{
		case 0: return 0xF;
		case 1: return 0x0;
		case 2: return 0x4;
		case 3: return 0xC;
		case 4: return 0x2;
		case 5: return 0x9;
		case 6: return 0x1;
		case 7: return 0xA;
		case 8: return 0xE;
		case 9: return 0x6;
		case 10: return 0x3;
		case 11: return 0xB;
		case 12: return 0x5;
		case 13: return 0xD;
		case 14: return 0x7;
		case 15: return 0x8;
		default: return 0x8;
	}
}
